#pragma once

//#include "ApproachTrace.h"
#include "Approach.h"
#include "Integrator.h"
#include "AsteroidOrbitParam.h"

class CSingleBodyApproachSearcher
{
public: 
	CSingleBodyApproachSearcher(ISimpleIntegratorInterface * pIntegrator, IGetCoord * pEphem, eBodies nBodyNum, CAsteroidOrbitParam::Ptr pAsteroidOrbitParam);

	CApproach::Ptr Check(double dTime, const SBody & body);
protected:
	double GetDistance(double dTime, const SBody & body, double dXdiff[3]);
	CApproach::Ptr Search(double dTime, SBody body, double dStep);
protected:
	double			m_dDetectDist;
	eBodies			m_nBodyNum;
	double			m_dPrevDist;
	double			m_dPrevTime;
	bool			m_bWasApproach;
	IGetCoord *		m_pEphem;
	double			m_dSearchAccuracy;

	CAsteroidOrbitParam::Ptr		m_pAsteroidOrbitParam;
	ISimpleIntegratorInterface *	m_pIntegrator;
};

class CApproachSearcher
{
	typedef list<CSingleBodyApproachSearcher> ListApprchSch;
public:
	CApproachSearcher(ISimpleIntegratorInterface * pIntegrator, IGetCoord * pEphem, const vector<eBodies> & vecBodysToSearch, CAsteroidOrbitParam::Ptr pAsteroidOrbitParam);
	ListPtrApproachs Check(double dTime, const SBody & body);
protected:
	ListApprchSch	m_listSearcher;
};

